<!DOCTYPE HTML>
<html lang="zh-CN">


<head>
    <meta charset="utf-8">
    <meta name="keywords" content="基于 Vue拓展的 v-xxx 库, 小康,xkloveme,博客">
    <meta name="description" content="
君问归期未有期，巴山夜雨涨秋池。 &amp;gt; 何当共剪西窗烛，却话巴山夜雨时。

作为vue轻车熟路的老司机，经常会用到一些指令，vue官方提供的指令又太少，无法满足旺盛的欲望，而每次要写一遍，终日郁郁寡欢，从小就教育我们乐于助人，为了将奉">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>基于 Vue拓展的 v-xxx 库 | 小康之家</title>
    <link rel="icon" type="image/x-icon, image/vnd.microsoft.icon" href="/favicon.ico">

    <link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/font-awesome/5.12.1/css/all.css">
    <link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/materialize/1.0.0/css/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/aos/3.0.0-beta.6/aos.css">
    <link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/animate.css/3.5.1/animate.min.css">
    <link rel="stylesheet" type="text/css" href="https://cdn.bootcss.com/lightgallery/1.6.11/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">
    
    <script src="https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js"></script>
    
<meta name="generator" content="Hexo 4.2.0"><link rel="alternate" href="/atom.xml" title="小康之家" type="application/atom+xml">
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>


<body >
    <header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper head-container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">小康之家</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fas fa-bars"></i></a>
<ul class="right nav-menu">
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/" class="waves-effect waves-light">
      
      <i class="fas fa-home" style="zoom: 0.6;"></i>
      
      <span>首页</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/tags" class="waves-effect waves-light">
      
      <i class="fas fa-tags" style="zoom: 0.6;"></i>
      
      <span>标签</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/categories" class="waves-effect waves-light">
      
      <i class="fas fa-bookmark" style="zoom: 0.6;"></i>
      
      <span>分类</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/archives" class="waves-effect waves-light">
      
      <i class="fas fa-archive" style="zoom: 0.6;"></i>
      
      <span>归档</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/about" class="waves-effect waves-light">
      
      <i class="fas fa-user-circle" style="zoom: 0.6;"></i>
      
      <span>关于</span>
    </a>
    
  </li>
  
  <li class="hide-on-med-and-down nav-item">
    
    <a href="/friends" class="waves-effect waves-light">
      
      <i class="fas fa-address-book" style="zoom: 0.6;"></i>
      
      <span>友情链接</span>
    </a>
    
  </li>
  
  <li>
    <a href="#searchModal" class="modal-trigger waves-effect waves-light">
      <i id="searchIcon" class="fas fa-search" title="搜索" style="zoom: 0.85;"></i>
    </a>
  </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">小康之家</div>
        <div class="logo-desc">
            
            小康のblog
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li class="m-nav-item">
	  
		<a href="/" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-home"></i>
			
			首页
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/tags" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-tags"></i>
			
			标签
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/categories" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-bookmark"></i>
			
			分类
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/archives" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-archive"></i>
			
			归档
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/about" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-user-circle"></i>
			
			关于
		</a>
          
        </li>
        
        <li class="m-nav-item">
	  
		<a href="/friends" class="waves-effect waves-light">
			
			    <i class="fa-fw fas fa-address-book"></i>
			
			友情链接
		</a>
          
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/xkloveme" class="waves-effect waves-light" target="_blank">
                <i class="fab fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>

        </div>

        
            <style>
  .nav-transparent .github-corner {
    display: none !important;
  }

  .github-corner {
    position: absolute;
    z-index: 10;
    top: 0;
    right: 0;
    border: 0;
    transform: scale(1.1);
  }

  .github-corner svg {
    color: #027aff;
    fill: #fff;
    height: 64px;
    width: 64px;
  }

  .github-corner:hover .octo-arm {
    animation: a 0.56s ease-in-out;
  }

  .github-corner .octo-arm {
    animation: none;
  }

  @keyframes a {
    0%,
    to {
      transform: rotate(0);
    }
    20%,
    60% {
      transform: rotate(-25deg);
    }
    40%,
    80% {
      transform: rotate(10deg);
    }
  }
</style>

<a
  href="https://github.com/xkloveme"
  class="github-corner tooltipped hide-on-med-and-down"
  target="_blank"
  data-tooltip="Fork Me"
  data-position="left"
  data-delay="50"
>
  <svg viewBox="0 0 250 250" aria-hidden="true">
    <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path>
    <path
      d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2"
      fill="currentColor"
      style="transform-origin: 130px 106px;"
      class="octo-arm"
    ></path>
    <path
      d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
      fill="currentColor"
      class="octo-body"
    ></path>
  </svg>
</a>

        
    </nav>

</header>

    



<div class="bg-cover pd-header post-cover" style="background-image: url('https://picsum.photos/600/300?t=wdy3yz471wg')">
    <div class="container" style="right: 0px;left: 0px;">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        基于 Vue拓展的 v-xxx 库
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>




<main class="post-container content">

    
    <link rel="stylesheet" href="https://cdn.bootcss.com/tocbot/4.10.0/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 15px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/vue/">
                                <span class="chip bg-color">vue</span>
                            </a>
                        
                            <a href="/tags/GitHub/">
                                <span class="chip bg-color">GitHub</span>
                            </a>
                        
                            <a href="/tags/%E6%8C%87%E4%BB%A4/">
                                <span class="chip bg-color">指令</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fas fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/%E5%89%8D%E7%AB%AF/" class="post-category">
                                前端
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                
                <div class="post-date info-break-policy">
                    <i class="far fa-calendar-minus fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2019-10-11
                </div>
                

                

                
                <div class="info-break-policy">
                    <i class="far fa-file-word fa-fw"></i>文章字数:&nbsp;&nbsp;
                    2k
                </div>
                

                
                <div class="info-break-policy">
                    <i class="far fa-clock fa-fw"></i>阅读时长:&nbsp;&nbsp;
                    8 分
                </div>
                
				
                
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="far fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
            
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <blockquote>
<p><strong>君问归期未有期，巴山夜雨涨秋池。</strong> &gt; <strong>何当共剪西窗烛，却话巴山夜雨时。</strong></p>
</blockquote>
<p>作为<code>vue</code>轻车熟路的老司机，经常会用到一些指令，<code>vue</code>官方提供的指令又太少，无法满足旺盛的欲望，而每次要写一遍，终日郁郁寡欢，从小就教育我们乐于助人，为了将奉献精神贯彻始终，用了这个库，空下来大把时间陪陪家人朋友岂不乐哉。</p>
<p>闲话少叙，直逼主题，毕竟我们是正经的官方软文。</p>
<ul>
<li><strong><a href="https://www.jixiaokang.com/vue-v-xxx/" target="_blank" rel="noopener">查看官网</a></strong></li>
<li><strong><a href="https://github.com/xkloveme/vue-v-xxx/" target="_blank" rel="noopener">查看源码</a></strong></li>
</ul>
<h2 id="什么是-vue-指令"><a href="#什么是-vue-指令" class="headerlink" title="什么是 vue 指令?"></a>什么是 vue 指令?</h2><hr>
<ul>
<li>在我们了解库之前,我们先回顾一下<code>Vue</code>指令</li>
</ul>
<h3 id="1-我们经常用的有一下几种指令"><a href="#1-我们经常用的有一下几种指令" class="headerlink" title="1. 我们经常用的有一下几种指令"></a>1. 我们经常用的有一下几种指令</h3><pre class=" language-js"><code class="language-js">v<span class="token operator">-</span>text 、 v<span class="token operator">-</span>html 、 v<span class="token operator">-</span>show 、 v<span class="token operator">-</span><span class="token keyword">if</span> 、 v<span class="token operator">-</span><span class="token keyword">else</span> 、v<span class="token operator">-</span><span class="token keyword">for</span> 、 v<span class="token operator">-</span>bind 、 v<span class="token operator">-</span>on 、
v<span class="token operator">-</span>model 、 v<span class="token operator">-</span>once</code></pre>
<blockquote>
<p>具体用法<a href="https://cn.vuejs.org/v2/guide/conditional.html" target="_blank" rel="noopener">前去官网</a>,不再赘述</p>
</blockquote>
<h3 id="什么是自定义指令"><a href="#什么是自定义指令" class="headerlink" title="什么是自定义指令?"></a>什么是自定义指令?</h3><blockquote>
<p>有的情况下，你仍然需要对普通 DOM 元素进行底层操作，这时候就会用到自定义指令.</p>
</blockquote>
<pre class=" language-js"><code class="language-js"><span class="token operator">&lt;</span>input  v<span class="token operator">-</span>focus<span class="token operator">></span><span class="token comment" spellcheck="true">// 为例</span>

<span class="token comment" spellcheck="true">// 在组件内部</span>
directives<span class="token punctuation">:</span> <span class="token punctuation">{</span>
  focus<span class="token punctuation">:</span> <span class="token punctuation">{</span>
  <span class="token comment" spellcheck="true">// 指令的定义</span>
  inserted<span class="token punctuation">:</span> <span class="token keyword">function</span> <span class="token punctuation">(</span>el<span class="token punctuation">)</span> <span class="token punctuation">{</span>
    el<span class="token punctuation">.</span><span class="token function">focus</span><span class="token punctuation">(</span><span class="token punctuation">)</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span></code></pre>
<h3 id="钩子函数"><a href="#钩子函数" class="headerlink" title="钩子函数"></a>钩子函数</h3><p>一个指令定义对象可以提供如下几个钩子函数 (均为可选)：</p>
<ul>
<li><p><code>bind</code>：只调用一次，指令第一次绑定到元素时调用。在这里可以进行一次性的初始化设置。</p>
</li>
<li><p><code>inserted</code>：被绑定元素插入父节点时调用 (仅保证父节点存在，但不一定已被插入文档中)。</p>
</li>
<li><p><code>update</code>：所在组件的 VNode 更新时调用，<strong>但是可能发生在其子 VNode 更新之前</strong>。指令的值可能发生了改变，也可能没有。但是你可以通过比较更新前后的值来忽略不必要的模板更新。</p>
</li>
<li><p><code>componentUpdated</code>：指令所在组件的 VNode <strong>及其子 VNode</strong> 全部更新后调用。</p>
</li>
<li><p><code>unbind</code>：只调用一次，指令与元素解绑时调用。</p>
</li>
</ul>
<h3 id="钩子函数的参数"><a href="#钩子函数的参数" class="headerlink" title="钩子函数的参数"></a>钩子函数的参数</h3><ul>
<li><code>el</code>：指令所绑定的元素，可以用来直接操作 DOM 。</li>
<li><code>binding</code>：一个对象，包含以下属性：<ul>
<li><code>name</code>：指令名，不包括 <code>v-</code> 前缀。</li>
<li><code>value</code>：指令的绑定值，例如：<code>v-my-directive=&quot;1 + 1&quot;</code> 中，绑定值为 <code>2</code>。</li>
<li><code>oldValue</code>：指令绑定的前一个值，仅在 <code>update</code> 和 <code>componentUpdated</code> 钩子中可用。无论值是否改变都可用。</li>
<li><code>expression</code>：字符串形式的指令表达式。例如 <code>v-my-directive=&quot;1 + 1&quot;</code> 中，表达式为 <code>&quot;1 + 1&quot;</code>。</li>
<li><code>arg</code>：传给指令的参数，可选。例如 <code>v-my-directive:foo</code> 中，参数为 <code>&quot;foo&quot;</code>。</li>
<li><code>modifiers</code>：一个包含修饰符的对象。例如：<code>v-my-directive.foo.bar</code> 中，修饰符对象为 <code>{ foo: true, bar: true }</code>。</li>
</ul>
</li>
<li><code>vnode</code>：Vue 编译生成的虚拟节点。</li>
<li><code>oldVnode</code>：上一个虚拟节点，仅在 <code>update</code> 和 <code>componentUpdated</code> 钩子中可用。</li>
</ul>
<h2 id="怎么安装-vue-v-xxx"><a href="#怎么安装-vue-v-xxx" class="headerlink" title="怎么安装 vue-v-xxx?"></a>怎么安装 vue-v-xxx?</h2><hr>
<blockquote>
<p>基于 vue 指令,又新增丰富一些常用的指令,看看是怎么使用的吧</p>
</blockquote>
<h3 id="安装"><a href="#安装" class="headerlink" title="安装"></a>安装</h3><ul>
<li>您可以通过 npm 安装,推荐使用 <code>npm</code> 的方式安装，它能更好地和 <code>webpack</code> 打包工具配合使用。</li>
</ul>
<pre class=" language-bash"><code class="language-bash">
<span class="token comment" spellcheck="true"># install vue-v-xxx</span>

 <span class="token function">npm</span> <span class="token function">install</span> vue-v-xxx --save

<span class="token comment" spellcheck="true"># or</span>

 yarn add vue-v-xxx --save
</code></pre>
<ul>
<li>您也可以通过 unpkg.com/vue-v-xxx 获取到最新版本的资源，在页面上引入 js 和 css 文件即可开始使用。</li>
</ul>
<pre class=" language-html"><code class="language-html"><span class="token comment" spellcheck="true">&lt;!-- 引入样式 --></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span> <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>stylesheet<span class="token punctuation">"</span></span> <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>https://unpkg.com/vue-v-xxx/lib/vue-v-xxx.css<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>

<span class="token comment" spellcheck="true">&lt;!-- 引入组件库 --></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>https://unpkg.com/vue-v-xxx<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script language-javascript"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span></code></pre>
<h3 id="使用"><a href="#使用" class="headerlink" title="使用"></a>使用</h3><ul>
<li>您可以在<code>main.js</code>里面全局注册,在组件内就可以应用了<a href="https://github.com/xkloveme/vue-v-xxx-project" target="_blank" rel="noopener">推荐工程</a></li>
</ul>
<pre class=" language-js"><code class="language-js"><span class="token keyword">import</span> Vue <span class="token keyword">from</span> <span class="token string">"vue"</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> App <span class="token keyword">from</span> <span class="token string">"./App"</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> Vxxx <span class="token keyword">from</span> <span class="token string">"vue-v-xxx"</span><span class="token punctuation">;</span>

<span class="token keyword">import</span> <span class="token string">"vue-v-xxx/lib/vue-v-xxx.css"</span><span class="token punctuation">;</span>

Vue<span class="token punctuation">.</span>config<span class="token punctuation">.</span>productionTip <span class="token operator">=</span> <span class="token boolean">false</span><span class="token punctuation">;</span>

Vue<span class="token punctuation">.</span><span class="token function">use</span><span class="token punctuation">(</span>Vxxx<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">/* eslint-disable no-new */</span>

<span class="token keyword">new</span> <span class="token class-name">Vue</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  el<span class="token punctuation">:</span> <span class="token string">"#app"</span><span class="token punctuation">,</span>

  components<span class="token punctuation">:</span> <span class="token punctuation">{</span> App <span class="token punctuation">}</span><span class="token punctuation">,</span>

  template<span class="token punctuation">:</span> <span class="token string">"&lt;App/>"</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
<ul>
<li>您可以通过 CDN 可以快速使用 vue-v-xxx 写出一个示例，您可以复制下面代码或<a href="https://codesandbox.io/s/vue-v-xxx-bndj4" target="_blank" rel="noopener">在线预览</a></li>
</ul>
<pre class=" language-html"><code class="language-html"><span class="token doctype">&lt;!DOCTYPE html></span>

<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>html</span><span class="token punctuation">></span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>head</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>meta</span> <span class="token attr-name">charset</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>utf-8<span class="token punctuation">"</span></span> <span class="token punctuation">/></span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>title</span><span class="token punctuation">></span></span>vue-v-xxx<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>title</span><span class="token punctuation">></span></span>

    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>link</span>
      <span class="token attr-name">rel</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>stylesheet<span class="token punctuation">"</span></span>
      <span class="token attr-name">href</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>https://unpkg.com/vue-v-xxx/lib/vue-v-xxx.css<span class="token punctuation">"</span></span>
    <span class="token punctuation">/></span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>head</span><span class="token punctuation">></span></span>

  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>body</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>div</span> <span class="token attr-name">id</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>app<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>
      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>h1</span> <span class="token attr-name">title</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>Welcome<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>欢迎使用 {{ value }}<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>h1</span><span class="token punctuation">></span></span>

      <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>button</span> <span class="token attr-name">v-copy</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>value<span class="token punctuation">"</span></span><span class="token punctuation">></span></span>Click me!<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>button</span><span class="token punctuation">></span></span>
    <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>div</span><span class="token punctuation">></span></span>
  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>body</span><span class="token punctuation">></span></span>

  <span class="token comment" spellcheck="true">&lt;!-- import Vue before vue-v-xxx --></span>

  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>https://unpkg.com/vue/dist/vue.js<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script language-javascript"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span>

  <span class="token comment" spellcheck="true">&lt;!-- import JavaScript --></span>

  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span> <span class="token attr-name">src</span><span class="token attr-value"><span class="token punctuation">=</span><span class="token punctuation">"</span>https://unpkg.com/vue-v-xxx/lib/vue-v-xxx.umd.js<span class="token punctuation">"</span></span><span class="token punctuation">></span></span><span class="token script language-javascript"></span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span>

  <span class="token tag"><span class="token tag"><span class="token punctuation">&lt;</span>script</span><span class="token punctuation">></span></span><span class="token script language-javascript">
    <span class="token keyword">new</span> <span class="token class-name">Vue</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
      el<span class="token punctuation">:</span> <span class="token string">"#app"</span><span class="token punctuation">,</span>

      data<span class="token punctuation">:</span> <span class="token punctuation">{</span>
        value<span class="token punctuation">:</span> <span class="token string">"vue-v-xxx"</span>
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
  </span><span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>script</span><span class="token punctuation">></span></span>
<span class="token tag"><span class="token tag"><span class="token punctuation">&lt;/</span>html</span><span class="token punctuation">></span></span></code></pre>
<h2 id="我们提供了那些额外的指令"><a href="#我们提供了那些额外的指令" class="headerlink" title="我们提供了那些额外的指令?"></a>我们提供了那些额外的指令?</h2><hr>
<h3 id="v-call-拨打指令"><a href="#v-call-拨打指令" class="headerlink" title="v-call 拨打指令"></a>v-call 拨打指令</h3><blockquote>
<p>该指令快速唤起拨打电话或者发送短信</p>
</blockquote>
<ul>
<li><p><a href="https://www.jixiaokang.com/vue-v-xxx/configurations/v-call.html" target="_blank" rel="noopener">在线预览</a></p>
</li>
<li><p>使用案例</p>
</li>
</ul>
<pre><code>&lt;template lang=&quot;pug&quot;&gt;
.v-xxx
  div(v-call=&quot;tel&quot;) 点击拨打☎️
  div(v-call:sms=&quot;10086&quot;) 点击发短信💬
&lt;/template&gt;
&lt;script&gt;
  export default {
    name: &#39;v-call&#39;,
    data() {
      return {
        tel: &#39;10086&#39;
      }
    }
  }
&lt;/script&gt;</code></pre><h3 id="v-copy-复制指令"><a href="#v-copy-复制指令" class="headerlink" title="v-copy 复制指令"></a>v-copy 复制指令</h3><blockquote>
<p>在很多情况下，我们需要复制操作</p>
</blockquote>
<ul>
<li><p><a href="https://www.jixiaokang.com/vue-v-xxx/configurations/v-copy.html" target="_blank" rel="noopener">在线预览</a></p>
</li>
<li><p>使用案例</p>
</li>
</ul>
<pre><code>&lt;template lang=&quot;pug&quot;&gt;
.v-xxx
  Button(@click=&quot;handleClick&quot; v-copy=&quot;value&quot;) 点击复制
  div
    textarea(placeholder=&quot;Paste here&quot; style=&quot;margin-top:40px;width:100%;height:100%;&quot;)
&lt;/template&gt;
&lt;script&gt;
  export default {
    name: &#39;v-copy&#39;,
    data() {
      return {
        value: &#39;&#39;
      }
    },
    methods: {
      handleClick(html = &#39;你复制了我,去粘贴吧&#39;) {
        this.value = html
      }
    }
  }
&lt;/script&gt;</code></pre><h3 id="v-debounce-防抖指令"><a href="#v-debounce-防抖指令" class="headerlink" title="v-debounce 防抖指令"></a>v-debounce 防抖指令</h3><blockquote>
<p><code>v-debounce</code> 支持传入防抖时间<code>v-debounce:500</code> 默认 500ms</p>
</blockquote>
<ul>
<li><a href="https://www.jixiaokang.com/vue-v-xxx/configurations/v-debounce.html" target="_blank" rel="noopener">在线预览</a></li>
</ul>
<pre><code>&lt;template lang=&quot;pug&quot;&gt;
.v-xxx
  h1 未加防抖
  h2 点击次数:{{num}}
  Button(@click=&quot;addNum&quot;) (点我)
  h1 加入防抖
  h2 点击次数:{{num2}}
  Button(v-debounce=&quot;addNum2&quot;) (点我)
&lt;/template&gt;
&lt;script&gt;
export default {
  name: &#39;v-debounce&#39;,
  data () {
    return {
      num: 0,
      num2: 0,
    }
  },
  methods: {
    addNum () {
      this.num++
    },
    addNum2 () {
      this.num2++
    }
  }
}
&lt;/script&gt;</code></pre><h3 id="v-throttle-节流指令"><a href="#v-throttle-节流指令" class="headerlink" title="v-throttle 节流指令"></a>v-throttle 节流指令</h3><blockquote>
<p><code>v-throttle</code> 支持传入防抖时间<code>v-throttle:2000</code> 默认 2s</p>
</blockquote>
<ul>
<li><a href="https://www.jixiaokang.com/vue-v-xxx/configurations/v-throttle.html" target="_blank" rel="noopener">在线预览</a></li>
</ul>
<pre><code>&lt;template lang=&quot;pug&quot;&gt;
.v-xxx
  h3 立即触发:{{num}}
  input(v-model=&quot;num&quot;)
  h3 节流后:{{num2}}
  input(v-throttle:2000=&quot;num2&quot;)
&lt;/template&gt;
&lt;script&gt;
  export default {
    name: &#39;v-throttle&#39;,
    data() {
      return {
        num: &#39;立即改变&#39;,
        num2: &#39;节流值&#39;
      }
    }
  }
&lt;/script&gt;</code></pre><h3 id="v-ellipsis-省略指令"><a href="#v-ellipsis-省略指令" class="headerlink" title="v-ellipsis 省略指令"></a>v-ellipsis 省略指令</h3><blockquote>
<p><code>v-ellipsis</code> 在表格中经常使用,<code>v-ellipsis</code>默认单行省略</p>
</blockquote>
<ul>
<li><a href="https://www.jixiaokang.com/vue-v-xxx/configurations/v-ellipsis.html" target="_blank" rel="noopener">在线预览</a></li>
</ul>
<pre><code>&lt;template lang=&quot;pug&quot;&gt;
.v-xxx
  div(v-ellipsis) {{des}}
  div(v-ellipsis:3)
    p {{des2}}
&lt;/template&gt;
&lt;script&gt;
export default {
  name: &#39;v-ellipsis&#39;,
  data() {
    return {
      des:
        &#39;单行省略单行省略单行省略单行省略单行省略单行省略单行省略单行省略单行省略单行省略单行省略单行省略单行省略单行省略单行省略单行省略&#39;,
      des2:
        &#39;多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略多行省略&#39;
    }
  }
}
&lt;/script&gt;</code></pre><h3 id="v-pin-固定指令"><a href="#v-pin-固定指令" class="headerlink" title="v-pin 固定指令"></a>v-pin 固定指令</h3><blockquote>
<p><code>v-pin</code> 支持传入定位位置和定位值<code>v-pin:left || top</code> 默认 left</p>
</blockquote>
<ul>
<li><a href="https://www.jixiaokang.com/vue-v-xxx/configurations/v-pin.html" target="_blank" rel="noopener">在线预览</a></li>
</ul>
<pre><code>&lt;template lang=&quot;pug&quot;&gt;
.v-xxx
  div(v-pin=&quot;200&quot;) 顶部200px
  div(v-pin:left=&quot;300&quot;) 左边300px
&lt;/template&gt;
&lt;script&gt;
  export default {
    name: &#39;v-pin&#39;
  }
&lt;/script&gt;</code></pre><h3 id="v-focus-聚焦指令"><a href="#v-focus-聚焦指令" class="headerlink" title="v-focus 聚焦指令"></a>v-focus 聚焦指令</h3><blockquote>
<p><code>v-focus</code> 在移动端登录时异常好用</p>
</blockquote>
<ul>
<li><a href="https://www.jixiaokang.com/vue-v-xxx/configurations/v-focus.html" target="_blank" rel="noopener">在线预览</a></li>
</ul>
<pre><code>&lt;template lang=&quot;pug&quot;&gt;
.v-xxx
  input(v-focus)
&lt;/template&gt;
&lt;script&gt;
export default {
  name: &#39;v-focus&#39;
}
&lt;/script&gt;</code></pre><h3 id="v-click-out-外部点击指令"><a href="#v-click-out-外部点击指令" class="headerlink" title="v-click-out 外部点击指令"></a>v-click-out 外部点击指令</h3><blockquote>
<p><code>v-click-out</code> 点击外部 dom 触发</p>
</blockquote>
<ul>
<li><a href="https://www.jixiaokang.com/vue-v-xxx/configurations/v-click-out.html" target="_blank" rel="noopener">在线预览</a></li>
</ul>
<pre><code>&lt;template lang=&quot;pug&quot;&gt;
.v-xxx
  div(style=&quot;border:1px solid red;width:200px;height:200px;&quot; @click=&quot;handleClick&quot; v-click-out=&quot;handleClickOut&quot;) {{name}}
&lt;/template&gt;
&lt;script&gt;
  export default {
    name: &#39;v-click-out&#39;,
    data() {
      return {
        name: &#39;内部&#39;
      }
    },
    methods: {
      handleClick() {
        this.name = &#39;您点击了内部&#39;
      },
      handleClickOut() {
        this.name = &#39;您点击了外部&#39;
      }
    }
  }
&lt;/script&gt;
</code></pre><h2 id="结束语"><a href="#结束语" class="headerlink" title="结束语"></a>结束语</h2><blockquote>
<p><strong>如果您有好的指令欢迎 👏 来提 issue,尽可能多的覆盖,一旦选用将获取神秘礼品,期待您的加入</strong></p>
</blockquote>
<h2 id="神交"><a href="#神交" class="headerlink" title="神交"></a>神交</h2><p>觉得不错的话给个<code>star</code></p>
<ul>
<li><a href="https://github.com/xkloveme/vue-v-xxx/" target="_blank" rel="noopener">GitHub</a></li>
<li><a href="https://www.cnblogs.com/xkloveme/" target="_blank" rel="noopener">blog</a></li>
</ul>

            </div>
            <hr/>

            

    <div class="reprint" id="reprint-statement">
        
            <div class="reprint__author">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-user">
                        文章作者:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="http://jixioakang.com" rel="external nofollow noreferrer">xkloveme</a>
                </span>
            </div>
            <div class="reprint__type">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-link">
                        文章链接:
                    </i>
                </span>
                <span class="reprint-info">
                    <a href="http://jixioakang.com/2019/10/11/2019-10-12-vue-v-xxx-ji-yu-vue-tuo-zhan-de-v-xxx-ku/">http://jixioakang.com/2019/10/11/2019-10-12-vue-v-xxx-ji-yu-vue-tuo-zhan-de-v-xxx-ku/</a>
                </span>
            </div>
            <div class="reprint__notice">
                <span class="reprint-meta" style="font-weight: bold;">
                    <i class="fas fa-copyright">
                        版权声明:
                    </i>
                </span>
                <span class="reprint-info">
                    本博客所有文章除特別声明外，均采用
                    <a href="https://creativecommons.org/licenses/by/4.0/deed.zh" rel="external nofollow noreferrer" target="_blank">CC BY 4.0</a>
                    许可协议。转载请注明来源
                    <a href="http://jixioakang.com" target="_blank">xkloveme</a>
                    !
                </span>
            </div>
        
    </div>

    <script async defer>
      document.addEventListener("copy", function (e) {
        let toastHTML = '<span>复制成功，请遵循本文的转载规则</span><button class="btn-flat toast-action" onclick="navToReprintStatement()" style="font-size: smaller">查看</a>';
        M.toast({html: toastHTML})
      });

      function navToReprintStatement() {
        $("html, body").animate({scrollTop: $("#reprint-statement").offset().top - 80}, 800);
      }
    </script>



            <div class="tag_share" style="display: block;">
                <div class="post-meta__tag-list" style="display: inline-block;">
                    
                        <div class="article-tag">
                            
                                <a href="/tags/vue/">
                                    <span class="chip bg-color">vue</span>
                                </a>
                            
                                <a href="/tags/GitHub/">
                                    <span class="chip bg-color">GitHub</span>
                                </a>
                            
                                <a href="/tags/%E6%8C%87%E4%BB%A4/">
                                    <span class="chip bg-color">指令</span>
                                </a>
                            
                        </div>
                    
                </div>
                <div class="post_share" style="zoom: 80%; width: fit-content; display: inline-block; float: right; margin: -0.15rem 0;">
                    <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    
    <div class="social-share" data-sites="twitter,facebook,google,qq,qzone,wechat,weibo,douban,linkedin" data-wechat-qrcode-helper="<p>微信扫一扫即可分享！</p>"></div>
    <script src="/libs/share/js/social-share.min.js"></script>
    

    

</div>

                </div>
            </div>
            
                <style>
  #reward {
    margin: 40px 0;
    text-align: center;
  }

  #reward .reward-link {
    font-size: 1.4rem;
    line-height: 38px;
  }

  #reward .btn-floating:hover {
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
  }

  #rewardModal {
    width: 320px;
  }

  #rewardModal .reward-title {
    margin: 15px auto;
    padding-bottom: 5px;
  }

  #rewardModal .modal-content {
    padding: 10px;
  }

  #rewardModal .close {
    position: absolute;
    right: 15px;
    top: 15px;
    color: rgba(0, 0, 0, 0.5);
    font-size: 1.3rem;
    line-height: 20px;
    cursor: pointer;
  }

  #rewardModal .close:hover {
    color: #ef5350;
    transform: scale(1.3);
    -moz-transform: scale(1.3);
    -webkit-transform: scale(1.3);
    -o-transform: scale(1.3);
  }

  #rewardModal .reward-tabs {
    margin: 0 auto;
    width: 210px;
  }

  .reward-tabs .tabs {
    height: 38px;
    margin: 10px auto;
    padding-left: 0;
  }

  .reward-content ul {
    padding-left: 0 !important;
  }

  .reward-tabs .tabs .tab {
    height: 38px;
    line-height: 38px;
  }

  .reward-tabs .tab a {
    color: #fff;
    background-color: #ccc;
  }

  .reward-tabs .tab a:hover {
    background-color: #ccc;
    color: #fff;
  }

  .reward-tabs .wechat-tab .active {
    color: #fff !important;
    background-color: #22ab38 !important;
  }

  .reward-tabs .alipay-tab .active {
    color: #fff !important;
    background-color: #019fe8 !important;
  }

  .reward-tabs .reward-img {
    width: 210px;
  }
</style>

<div id="reward">
  <a
    href="#rewardModal"
    class="reward-link modal-trigger btn-floating btn-medium waves-effect waves-light red"
    >赏</a
  >

  <!-- Modal Structure -->
  <div id="rewardModal" class="modal">
    <div class="modal-content">
      <a class="close modal-close"><i class="fas fa-times"></i></a>
      <h4 class="reward-title">你的赏识是我前进的动力</h4>
      <div class="reward-content">
        <div class="reward-tabs">
          <ul class="tabs row">
            <li class="tab col s6 alipay-tab waves-effect waves-light">
              <a href="#alipay">支付宝</a>
            </li>
            <li class="tab col s6 wechat-tab waves-effect waves-light">
              <a href="#wechat">微 信</a>
            </li>
          </ul>
          <div id="alipay">
            <img
              src="/medias/reward/alipay.jpg"
              class="reward-img"
              alt="支付宝打赏二维码"
            />
          </div>
          <div id="wechat">
            <img
              src="/medias/reward/wechat.png"
              class="reward-img"
              alt="微信打赏二维码"
            />
          </div>
        </div>
      </div>
    </div>
  </div>
</div>

<script>
  $(function() {
    $(".tabs").tabs();
  });
</script>

            
        </div>
    </div>

    
        <link rel="stylesheet" href="https://cdn.bootcss.com/gitalk/1.6.2/gitalk.min.css">
<link rel="stylesheet" href="/css/my-gitalk.css">

<div class="card gitalk-card" data-aos="fade-up">
    <div class="comment_headling" style="font-size: 20px; font-weight: 700; position: relative; left: 20px; top: 15px; padding-bottom: 5px;">
        <i class="fas fa-comments fa-fw" aria-hidden="true"></i>
        <span>评论</span>
    </div>
    <div id="gitalk-container" class="card-content"></div>
</div>

<script src="https://cdn.bootcss.com/gitalk/1.6.2/gitalk.min.js"></script>
<script>
    let gitalk = new Gitalk({
        clientID: 'f1e60c7afa53a51926b5',
        clientSecret: '2430231be04e68f6ba8ccf331c537cc19f50a0bd',
        repo: 'xkloveme.github.io',
        owner: 'xkloveme',
        admin: "xkloveme",
        id: '2019-10-11T16-00-00',
        distractionFreeMode: false  // Facebook-like distraction free mode
    });

    gitalk.render('gitalk-container');
</script>
    

    

    

    

    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fas fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2020/03/13/2020-03-14-yue-zai-chun-tian-xiang-jian/">
                    <div class="card-image">
                        
                        <img src="https://s1.ax1x.com/2020/03/14/8l3Eh6.png" class="responsive-img" alt="约在春天相见">
                        
                        <span class="card-title">约在春天相见</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            

《约在春天相见》词曲：大雄我们约在春天相见那是多么美好的画面站在珞珈山下我们白衣翩翩和樱花笑成了一片
我们约在春天相见穿过这个冬天的梦魇户部巷的炊烟暖不了冰冷防线谁比我们更理解想念
穿越死亡的我们啊泪水往下咽雾锁长江 黄鹤飞不见魔鬼的威
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="far fa-clock fa-fw icon-date"></i>2020-03-13
                        </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E7%90%90%E7%A2%8E/" class="post-category">
                                    琐碎
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/%E4%BA%BA%E7%94%9F%E7%99%BE%E6%80%81/">
                        <span class="chip bg-color">人生百态</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fas fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2019/10/11/2019-10-12-ru-he-shang-chuan-zi-ji-de-ui-zu-jian-bao/">
                    <div class="card-image">
                        
                        
                        <img src="https://picsum.photos/600/300" class="responsive-img" alt="如何上传自己的UI组件包">
                        
                        <span class="card-title">如何上传自己的UI组件包</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            开篇
西风吹老洞庭波，一夜湘君白发多。醉后不知天在水，满船清梦压星河。

前言身为程序员,还没有自己的包,总感觉缺点什么,女朋友和包至少占一样吧.正如上战场没有扛枪的士兵,吃饭少了筷子一样,令人心情不愉悦.同时经常会有面试官会问一个犀利的问
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="far fa-clock fa-fw icon-date"></i>2019-10-11
                            </span>
                        <span class="publish-author">
                            
                            <i class="fas fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/%E5%89%8D%E7%AB%AF/" class="post-category">
                                    前端
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/vue/">
                        <span class="chip bg-color">vue</span>
                    </a>
                    
                    <a href="/tags/GitHub/">
                        <span class="chip bg-color">GitHub</span>
                    </a>
                    
                    <a href="/tags/%E6%95%99%E7%A8%8B/">
                        <span class="chip bg-color">教程</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>

</div>


<script>
    $('#articleContent').on('copy', function (e) {
        // IE8 or earlier browser is 'undefined'
        if (typeof window.getSelection === 'undefined') return;

        var selection = window.getSelection();
        // if the selection is short let's not annoy our users.
        if (('' + selection).length < Number.parseInt('120')) {
            return;
        }

        // create a div outside of the visible area and fill it with the selected text.
        var bodyElement = document.getElementsByTagName('body')[0];
        var newdiv = document.createElement('div');
        newdiv.style.position = 'absolute';
        newdiv.style.left = '-99999px';
        bodyElement.appendChild(newdiv);
        newdiv.appendChild(selection.getRangeAt(0).cloneContents());

        // we need a <pre> tag workaround.
        // otherwise the text inside "pre" loses all the line breaks!
        if (selection.getRangeAt(0).commonAncestorContainer.nodeName === 'PRE') {
            newdiv.innerHTML = "<pre>" + newdiv.innerHTML + "</pre>";
        }

        var url = document.location.href;
        newdiv.innerHTML += '<br />'
            + '来源: 小康之家<br />'
            + '文章作者: xkloveme<br />'
            + '文章链接: <a href="' + url + '">' + url + '</a><br />'
            + '本文章著作权归作者所有，任何形式的转载都请注明出处。';

        selection.selectAllChildren(newdiv);
        window.setTimeout(function () {bodyElement.removeChild(newdiv);}, 200);
    });
</script>


<!-- 代码块功能依赖 -->
<script type="text/javascript" src="/libs/codeBlock/codeBlockFuction.js"></script>

<!-- 代码语言 -->

<script type="text/javascript" src="/libs/codeBlock/codeLang.js"></script>

    
<!-- 代码块复制 -->

<script type="text/javascript" src="/libs/codeBlock/codeCopy.js"></script>


<!-- 代码块收缩 -->

<script type="text/javascript" src="/libs/codeBlock/codeShrink.js"></script>


<!-- 代码块折行 -->

<style type="text/css">
code[class*="language-"], pre[class*="language-"] { white-space: pre !important; }
</style>

    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="far fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fas fa-list-ul"></i>
    </a>
</div>


<script src="https://cdn.bootcss.com/tocbot/4.10.0/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            // headingsOffset: -205,
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).hide();
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).show();
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>

    

</main>



    <footer class="page-footer bg-color">
  <div class="container row center-align">
    <div class="col s12 m8 l8 copy-right">
      Copyright&nbsp;&copy;
      <span id="year">年份</span>
      <a href="http://jixioakang.com" target="_blank">xkloveme</a>
      |&nbsp;Powered by&nbsp;<a href="https://hexo.io/" target="_blank">Hexo</a>
      <br />
       &nbsp;<i
        class="fas fa-chart-area"
      ></i
      >&nbsp;站点总字数:&nbsp;<span class="white-color"
        >141.5k</span
      >&nbsp;字      
      <span id="busuanzi_container_site_pv">
        |&nbsp;<i class="far fa-eye"></i>&nbsp;总访问量:&nbsp;<span
          id="busuanzi_value_site_pv"
          class="white-color"
        ></span
        >&nbsp;次
      </span>
       
      <span id="busuanzi_container_site_uv">
        |&nbsp;<i class="fas fa-users"></i>&nbsp;总访问人数:&nbsp;<span
          id="busuanzi_value_site_uv"
          class="white-color"
        ></span
        >&nbsp;人
      </span>
      
      <br />
      
      <span id="sitetime">载入运行时间...</span>
      <script>
        function siteTime() {
          window.setTimeout("siteTime()", 1000);
          var seconds = 1000;
          var minutes = seconds * 60;
          var hours = minutes * 60;
          var days = hours * 24;
          var years = days * 365;
          var today = new Date();
          var startYear = "2017";
          var startMonth = "3";
          var startDate = "13";
          var startHour = "0";
          var startMinute = "0";
          var startSecond = "0";
          var todayYear = today.getFullYear();
          var todayMonth = today.getMonth() + 1;
          var todayDate = today.getDate();
          var todayHour = today.getHours();
          var todayMinute = today.getMinutes();
          var todaySecond = today.getSeconds();
          var t1 = Date.UTC(
            startYear,
            startMonth,
            startDate,
            startHour,
            startMinute,
            startSecond
          );
          var t2 = Date.UTC(
            todayYear,
            todayMonth,
            todayDate,
            todayHour,
            todayMinute,
            todaySecond
          );
          var diff = t2 - t1;
          var diffYears = Math.floor(diff / years);
          var diffDays = Math.floor(diff / days - diffYears * 365);
          var diffHours = Math.floor(
            (diff - (diffYears * 365 + diffDays) * days) / hours
          );
          var diffMinutes = Math.floor(
            (diff - (diffYears * 365 + diffDays) * days - diffHours * hours) /
              minutes
          );
          var diffSeconds = Math.floor(
            (diff -
              (diffYears * 365 + diffDays) * days -
              diffHours * hours -
              diffMinutes * minutes) /
              seconds
          );
          if (startYear == todayYear) {
            document.getElementById("year").innerHTML = todayYear;
            document.getElementById("sitetime").innerHTML =
              "本站已安全运行 " +
              diffDays +
              " 天 " +
              diffHours +
              " 小时 " +
              diffMinutes +
              " 分钟 " +
              diffSeconds +
              " 秒";
          } else {
            document.getElementById("year").innerHTML =
              startYear + " - " + todayYear;
            document.getElementById("sitetime").innerHTML =
              "本站已安全运行 " +
              diffYears +
              " 年 " +
              diffDays +
              " 天 " +
              diffHours +
              " 小时 " +
              diffMinutes +
              " 分钟 " +
              diffSeconds +
              " 秒";
          }
        }
        setInterval(siteTime, 1000);
      </script>
      
      <br />
      
    </div>
    <div class="col s12 m4 l4 social-link social-statis">
      
    <a href="https://github.com/xkloveme" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fab fa-github"></i>
    </a>



    <a href="mailto:xkloveme@gmail.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fas fa-envelope-open"></i>
    </a>





    <a href="https://twitter.com/xkloveme" class="tooltipped" target="_blank" data-tooltip="关注我的Twitter: https://twitter.com/xkloveme" data-position="top" data-delay="50">
        <i class="fab fa-twitter"></i>
    </a>









    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fas fa-rss"></i>
    </a>


    </div>
  </div>
</footer>

<div class="progress-bar"></div>


    <!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fas fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字"
                   class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
    <!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fas fa-arrow-up"></i>
    </a>
</div>


    <script src="https://cdn.bootcss.com/materialize/1.0.0/js/materialize.min.js"></script>
    <script src="https://cdn.bootcss.com/masonry/4.0.0/masonry.pkgd.min.js"></script>
    <script src="https://cdn.bootcss.com/aos/3.0.0-beta.6/aos.js"></script>
    <script src="https://cdn.bootcss.com/scrollprogress/3.0.2/scrollProgress.min.js"></script>
    <script src="https://cdn.bootcss.com/lightgallery/1.6.11/js/lightgallery-all.min.js"></script>
    <script src="/js/matery.js"></script>

    <!-- Global site tag (gtag.js) - Google Analytics -->

<script async src="https://www.googletagmanager.com/gtag/js?id=UA-102352377-2"></script>
<script>
    window.dataLayer = window.dataLayer || [];
    function gtag() {
        dataLayer.push(arguments);
    }

    gtag('js', new Date());
    gtag('config', 'UA-102352377-2');
</script>


    <!-- Baidu Analytics -->

    <!-- Baidu Push -->

<script>
    (function () {
        var bp = document.createElement('script');
        var curProtocol = window.location.protocol.split(':')[0];
        if (curProtocol === 'https') {
            bp.src = 'https://zz.bdstatic.com/linksubmit/push.js';
        } else {
            bp.src = 'http://push.zhanzhang.baidu.com/push.js';
        }
        var s = document.getElementsByTagName("script")[0];
        s.parentNode.insertBefore(bp, s);
    })();
</script>

    
    <script src="/libs/others/clicklove.js" async="async"></script>
    
    
    <script async src="/libs/others/busuanzi.pure.mini.js"></script>
    

    

    

    

    

    
    <script type="text/javascript" src="/libs/background/ribbon-dynamic.js" async="async"></script>
    
    
    
    <script src="/libs/instantpage/instantpage.js" type="module"></script>
    

</body>

</html>
